const express = require('express')
// gzip压缩
const compression = require('compression')

// 配置更安全的https服务器
const https = require('https')
const fs = require('fs')

const app = express()

// 读取公钥cert和私钥key
const options = {
  cert: fs.readFileSync('./full_chain.pem'),
  key: fs.readFileSync('./private.key')
}

// app.use(compression())压缩，一定要在静态资源托管前面
app.use(compression())

// 静态资源托管
app.use(express.static('./dist'))

// http端口80
app.listen(80, ()=>{
  console.log('服务器已启动，http://127.0.0.1')
})

// https端口443
// https.createServer(options, app).listen(443)
